import api from '../modules/api';


export default {
    namespaced:true,
    state:{
        pageSize:5,
        currentPage:1,
        total:1,
        pages:1,
    },
    mutations:{
        //---每页显示几条数据
        setPageSize(state,newData){
            state.pageSize = newData;
            state.currentPage = 1 ;
        },
        //---设置当前的页数--
        setCurrentPage(state,newData){
            state.currentPage = newData;
        }
    },
    actions:{
        //获取教师信息
        async getTeachers(context,newData){
            const data = await api.teachers.getTeachers({
                ...newData,
                pageSize:context.state.pageSize,
                currentPage:context.state.currentPage
            });
                context.state.total = data.data.total
            return data
        },
        //新增教师信息
        async addTeachers(context,newTeacher){
            const data = await api.teachers.addTeachers(newTeacher);
            return data
        }
    },
}


























